<?php
namespace app\admin\model;

use think\Model;
class Customers extends Model
{




    //验证与处理添加客户信息
    public function get_add($posts){
        //判断必填项不可为空
        if($posts['name']=='' || $posts['customer_consultant_id']=='' || $posts['customer_case_number']==''){
            return 999;
        }else{
            //判断是否存在相同的客户名
            $judge['name'] = $posts['name'];
            $arr = $this->table('d_customer')->where($judge)->select();
            if($arr->isEmpty()){
                $res = $this->table('d_customer')->insert($posts);
                return $res;
            }else{
                return 999;
            }
        }
    }

    public function user_h($id){
        $where['branch'] = $id;
        $arr = $this->table('d_user')->where($where)->select();
        return $arr;
    }


    //修改客户信息
    public function get_edits($posts,$ids){
        //判断必填项不可为空
        if($posts['name']=='' || $posts['customer_consultant_id']=='' || $posts['customer_case_number']==''){
            return 999;
        }else{
            //修改
            $res = $this->table('d_customer')->where('id='.$ids)->update($posts);
            return $res;
        }
    }
}